<?php
require_once '../Classes/Feed.php';
require_once '../Classes/Entry.php';

class RssSimpleParser
{
	public function parse($path)
	{
		$xml= simplexml_load_file($path);
		$arrFeeds = new Feed;
		$arrFeeds->entries = array();
		$arrFeeds->link = $xml->channel->link[0];
		$arrFeeds->title = $xml->channel->title[0];
		$arrFeeds->description = $xml->channel->description[0];

		foreach ($xml->channel->item as $item)
		{
			$entry = new Entry();
			$entry->title = $item->title;
			$entry->link = $item->link;
			$entry->date = $item->pubDate;
			$entry->desc = $item->description;
			$entry->author = $item->author;
			$entry->imageUrl = $item->enclosure[0]['url'];
			array_push($arrFeeds->entries, $entry);
		}
		return $arrFeeds;
	}
}
?>